"auto";
//初始化参数
speed = 1;
float = 1.25;

height = device.height;
width = device.width;
setScreenMetrics(width, height);

console.show()
console.log('开始任务...')
console.log('按音量下键停止')


function registerKey() {
    events.observeKey()
    events.onKeyDown('volume_down', function (event) {
        console.log('脚本停止了')
        exit()
    })
}
threads.start(registerKey)


exit();
var score = text("领积分").findOne().bounds();
click(score.centerX(), score.centerY());
exit();

var txt = className("EditText").text("搜索").findOne();

    txt.setText("支付宝会员");
    sleep(200);
    txt.click();

sleep(1000);
exit();



exit();

/**
 * 通过文字内容模拟点击按钮
 * @param content 按钮文字内容
 * @param type 点击类型，默认为text点击
 * @param sleepTime 等待时间，默认1000毫秒
 */
function clickContent(content, type, sleepTime) {
    var type = type || "text";
    var sleepTime = sleepTime || 1000;
    sleep(sleepTime * float * speed);
    if (type == "text") {
        var button = text(content).findOne();
    } else {
        var button = desc(content).findOne();
    }
    clickButton(button);
    return button;
}

function clickButton(button) {
    var bounds = button.bounds();
    press(random(bounds.left, bounds.right), random(bounds.top, bounds.bottom), random(50, 350));
}